/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.com.smart.hawk.utilities;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JInternalFrame;

/**
 * Esta clase singleton se encarga de manejar las instancias de las vistas
 * @author Andres
 */
public class HawkViewMgr {

    private static HawkViewMgr instance;
    HashMap<Class, Object> listaInstancias;

    private HawkViewMgr() {
        listaInstancias = new HashMap();
    }

    public void removeObjectInstance(Class name) {
        listaInstancias.remove(name);
    }

    public static HawkViewMgr getInstance() {

        if (instance == null) {
            instance = new HawkViewMgr();
        }
        return instance;
    }

    public Object getObjectInstance(Class name) {
        return listaInstancias.get(name);

    }

    public void setObjectInstance(Object clazz) {
        listaInstancias.put(clazz.getClass(), clazz);
    }

    public void removeAll() {
        if (listaInstancias.size() > 0) {
            Iterator iterator = listaInstancias.entrySet().iterator();

            while (iterator.hasNext()) {

                Map.Entry e = (Map.Entry) iterator.next();
                JInternalFrame jif = (JInternalFrame) e.getValue();
                jif.dispose();
            }

            listaInstancias.clear();
        }
    }
}
